# encoding: utf-8
""" 
@version: v1.0 
@author: autumner 
@license: Apache Licence  
@contact: 18322313385@163.com 
@site:  https://gitee.com/autumner/pythoncookbook
@software: PyCharm 
@file: net_requests.py 
@time: 2019/7/10 下午1:11
"""
'''
使用第三方库requests
'''
import requests

# 设置URL
url = 'http://httpbin.org/post'

# 设置参数
params = {
    'username' : 'zhangsan',
    'address' : 'China.Tianj'
}

# 设置HTTP的头
headers = {
    'User-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36',
    'Spam' : 'Eggs'
}

# 发送POST请求
resp = requests.post(url, data=params, headers=headers)

# 返回text,content,json结果
print(resp.text)
print(resp.content)
print(resp.json())
